﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar.Metro;
using DevComponents.DotNetBar.Controls;
using PlanningGIS.ManageUtility;
//using PlanningGIS.Resources;

namespace PlanningGIS.Manager
{
    /// <summary>
    /// 启动界面控件
    /// </summary>
    public partial class StartControl : DevComponents.DotNetBar.Controls.SlidePanel
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public StartControl()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 大小改变
        /// </summary>
        /// <param name="e"></param>
        protected override void OnResize(EventArgs e)
        {
            lblTitle.Location = new Point((this.Width - lblTitle.Width) / 2 + 16, 3);
            itmpnlMenus.Location = new Point((this.Width - itmpnlMenus.Width) / 2 + 16, ((this.Height - lblTitle.Height - 16) - itmpnlMenus.Height) / 2 + lblTitle.Height + 16);
            base.OnResize(e);
        }

        /// <summary>
        /// 
        /// </summary>
        private BillCommands _Commands;
        /// <summary>
        /// 获取或设置与控件关联的命令。
        /// </summary>
        public BillCommands Commands
        {
            get { return _Commands; }
            set
            {
                if (value != _Commands)
                {
                    BillCommands oldcmd = _Commands;
                    _Commands = value;
                    OnCommandsChanged(oldcmd, value);
                }
            }
        }

        /// <summary>
        /// 命令按钮改变事件
        /// </summary>
        /// <param name="oldCmd">Old property value</param>
        /// <param name="newCmd">New property value</param>
        protected virtual void OnCommandsChanged(BillCommands oldCmd, BillCommands newCmd)
        {
            mnuFunction.Command = newCmd != null ? newCmd.FunctionCommands.New : null;
            mnuToc.Command = newCmd != null ? newCmd.TocCommands.New : null;
            mnuData.Command = newCmd != null ? newCmd.DataCommands.New : null;
            mnuDepartment.Command = newCmd != null ? newCmd.DepartmentCommands.New : null;
            mnuRole.Command = newCmd != null ? newCmd.RoleCommands.New : null;
            mnuUser.Command = newCmd != null ? newCmd.UserCommands.New : null;
            mnuAdUser.Command= newCmd != null ? newCmd.AdUserCommands.New : null;
            mnuLog.Command = newCmd != null ? newCmd.LogCommands.New : null;
            mnuSecuritySet.Command = newCmd != null ? newCmd.SecuritySetCommands.New : null;
            mnuMXD.Command = newCmd != null ? newCmd.MXDCommands.New : null;

            //if (ManageHelper.RegionStarted)
            //{
            //    mnuSecuritySet.Tooltip = "单击禁用范围权限";
            //    mnuSecuritySet.TitleText = "已启用";
            //    mnuSecuritySet.Image = ResourcesHelper.GetImage("Other.Started.png");
            //}
            //else
            //{
            //    mnuSecuritySet.Tooltip = "单击启用范围权限";
            //    mnuSecuritySet.TitleText = "已禁用";
            //    mnuSecuritySet.Image = ResourcesHelper.GetImage("Other.NoStarted.png");
            //}
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mnuRegion_Click(object sender, EventArgs e)
        {
            //if (ManageHelper.RegionStarted)
            //{
            //    ManageHelper.RegionStarted = false;
            //    mnuSecuritySet.Tooltip = "单击启用范围权限";
            //    mnuSecuritySet.TitleText = "已禁用";
            //    mnuSecuritySet.Image = ResourcesHelper.GetImage("Other.NoStarted.png");
            //}
            //else
            //{
            //    ManageHelper.RegionStarted = true;
            //    mnuSecuritySet.Tooltip = "单击禁用范围权限";
            //    mnuSecuritySet.TitleText = "已启用";
            //    mnuSecuritySet.Image = ResourcesHelper.GetImage("Other.Started.png");
            //}
        }


    }
}
